<script type="text/javascript">
function delF() {
	if(confirm('คุณต้องการลบข้อมูลที่เลือกไว้หรือไม่')==true) {
	var frm = document.forms["myForm"];
	frm.action = "<?=site_url()?>SchoolInfo/delete";
	frm.submit();
	}
}
</script>
<div id="mainContent">
<form name="myForm" action="<?=site_url()?>SchoolInfo/search" method="post">
<table width="400px" align="center" cellpadding="2" cellspacing="2" style="border: 1px solid #0000FF; background-color: #FFFFFF">
  <tr bgcolor="#000974">
    <td colspan="2" align="left" bgcolor="#000974" style="color:#FFFFFF;"><label>.:: ค้นหาโรงเรียนในสังกัด</label></td>
  </tr>
  <tr>
    <td align="right"><label>ชื่อโรงเรียนในสังกัด</label></td>
    <td align="left">
      <input name="txtTitle" type="text" id="txtTitle" value="<?php if(isset($key)) echo $key; ?>" />    </td>
  </tr>
  
  <tr>
    <td align="right">&nbsp;</td>
    <td align="left"><input type="submit" name="button" id="button" value="ค้นหาข้อมูล" /></td>
  </tr>
  <tr style="height:10px;">
    <td colspan="2"></td>
  </tr>
</table>
<br/>
<input type="hidden" name="txtId" id="txtId" />
<table width="500px" align="center" cellpadding="0" cellspacing="0" style="border: 1px solid #0000FF; background-color: #FFFFFF">
 	<tr bgcolor="#000974">
 		<?php
 			if($this->session->userdata('profile') == 'Administrator') {
 				echo '<td width="50px" align="center"><input type="button" value=" ลบ " onclick="delF()" ></td>';		
 			}	?>
		<td><div align="center" style="color:#FFFFFF;"><strong>ชื่อโรงเรียนในสังกัด</strong></div></td>
        <td><div align="center" style="color:#FFFFFF;"><strong>รายละเอียด        </strong></div></td>
 	</tr>
 	
 	<?php 
 		for($i = 0; $i < count($data); $i++) {
 			if($i % 2 == 0) {
 				echo "<tr id='$i'>";
 			} else {
 				echo "<tr id='$i' bgcolor='#C6E2FF'>";
 			}?>
 		<?php
		 			if($this->session->userdata('profile') == 'Administrator') { ?>
		 				<td align="center"><input type="checkbox" name="txtDel[]" value="<?=$data[$i]->school_id?>" > </td>	
		 		<?php }?>
 		<td><div align="left"><?php echo $data[$i]->school_name;?></div></td>
 	  	<td>
 	  		<div align="center">
 	  			<input id="img<?php echo $i;?>" name="img<?php echo $i;?>" type="image" src="<?=base_url()?>images/detail_b.png" onmouseout="toBlack(this);" onmouseover="toColor(this);" value="<?php echo $data[$i]->school_id;?>" width="25" height="25" onclick="setID(this);">
 	  		</div>
 	  	</td>
 	  	</tr>	
 	<?php } ?>
</table>
</form>

<script type="text/javascript">
function toBlack(obj) {
	obj.src = '<?=base_url()?>images/detail_b.png';
}
function toColor(obj) {
	obj.src = '<?=base_url()?>images/detail.png';
}
function setID(obj) {
	document.getElementById('txtId').value = obj.value;
	var frm = document.forms["myForm"];
	frm.action = "<?=site_url()?>SchoolInfo/detail";
	frm.submit();	
}
</script>
</div>
